package 公司真题.美团;

import java.security.Key;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class _数数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (n == 0 || k == 0) {
            throw new IllegalArgumentException();
        }
        sc.nextLine();
        int[] arr = new int[n];
        int index = 0;
        while (sc.hasNext()) {
            arr[index++] = sc.nextInt();
        }

        for (int i = 0; i < arr.length - k + 1; i++) {
            Map<Integer, Integer> map = new HashMap<>();
            int maxCount = 1;
            for (int j = i;j < k + i; j++) {
                map.put(arr[j], map.getOrDefault(arr[j], 0) + 1);
                maxCount = Math.max(maxCount, map.get(arr[j]));
            }
            int minValue = Integer.MAX_VALUE;
            for (Integer key : map.keySet()) {
                if (map.get(key) == maxCount) {
                    minValue = Math.min(minValue, key);
                }
            }
            System.out.println(minValue);
        }
    }
}
